/**
 *  main.cpp
 *  AwkwardCubed
 *
 *  Date: 20/08/2013
 *
 *  Language: C++
 *
 *  @author Carl mcCaffrey
 *
 */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include "sys/system.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);
	UNREFERENCED_PARAMETER(nCmdShow);

	Timer timer;
	System system;
	if(!system.Init(&hInstance, &timer)){
		return -1;
	}

	MSG msg;

	timer.Init();
	timer.Reset();

	while(true){
		if(PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)){
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}else{
			if(msg.message != WM_QUIT){
				system.Update();
			}else{
				system.Shutdown();
			}
		}
	}

	return 0;
}